package net.csdn.business.gateway;

import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;

import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
import java.util.concurrent.CountDownLatch;

@SpringBootTest
class OpenatomGatewayApplicationTests {

    @Test
    void contextLoads() {
    }

    public static void main(String[] args) throws InterruptedException {
        //Flux.interval(Duration.of(100, ChronoUnit.MILLIS)).window(1001).take(2).toStream().forEach(System.out::println);
        Integer[] fwArray = new Integer[]{1,2,3,4};
       /* Flux.fromArray(fwArray).filterWhen(item ->{
            return Mono.just(item % 2 == 0);
        }).subscribe(result ->{
            System.out.println(result);
        });*/

//测试二，结果 1 2 3 4，因为考虑Flux.just(true,false,false)
//的第一个值true
        Flux.fromArray(fwArray).filterWhen(item ->{
            return Flux.just(true, false, false);
        }).subscribe(result ->{
            System.out.println(result);
        });

//测试三，结果空，因为考虑Flux.just(false, true, false)
//的第一个值false
       /* Flux.fromArray(fwArray).filterWhen(item ->{
            return Flux.just(false, true, false);
        }).subscribe(result ->{
            System.out.println(result);
        });*/


    }
}
